<script src="<?php echo base_url();?>js/knockout-1.2.1.js"></script>

<p>&nbsp;</p>
<div align="center">
  <h1>Raw Material Inspection Report (Pulp Strength)</h1>
</div>
<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" class="font">
  <tr>
    <td width="12%" height="30">Date</td>
    <td width="27%" height="30"> :
      <input id="datepicker" data-bind="value: departure" /></td>
    <td width="18%" height="30">Pulp</td>
    <td width="43%" height="30"> :
      <select name="ticket" class="select" id="ticket3">
        <option value="NBKP">NBKP</option>
        <option value="LBKP1">LBKP1</option>
        <option value="LBKP2">LBKP2</option>
        <option value="Broke">Broke</option>
        <option value="Machine chest">Machine chest</option>
      </select></td>
  </tr>
  <tr>
    <td height="30">Time</td>
    <td height="30"> :
      <input type="text" name="timepicker" id="timepicker" /></td>
    <td height="30">Brand</td>
    <td height="30"> :
      <select name="ticket2" class="select" id="ticket4">
        <option value="PPPC">PPPC</option>
        <option value="Canfor">Canfor</option>
        <option value="Celgra">Celgra</option>
        <option value="Crestbrook">Crestbrook</option>
        <option value="Crofton">Crofton</option>
        <option value="Enopine">Enopine</option>
        <option value="Hinton">Hinton</option>
        <option value="Sodra">Sodra</option>
      </select></td>
  </tr>
  <tr>
    <td height="30">Type</td>
    <td height="30"> :
      <select name="ticket5" class="select" id="ticket1">
        <option value="PPC PMW">PPC PMW</option>
        <option value="LPP">LPP</option>
        <option value="OSP PRO-NEW">OSP PRO-NEW</option>
      </select></td>
    <td height="30">Problem</td>
    <td height="30"> :
      <input name="textfield21" type="text" class="k-textbox" id="textfield21"/></td>
  </tr>
  <tr>
    <td height="30">Gram</td>
    <td height="30"> :
      <select name="ticket3" class="select" id="ticket2">
        <option value="60">60</option>
        <option value="64">64</option>
        <option value="70">70</option>
        <option value="75">75</option>
        <option value="80">80</option>
        <option value="90">90</option>
        <option value="100">100</option>
      </select></td>
    <td height="30">&nbsp;</td>
    <td height="30">&nbsp;</td>
  </tr>
</table>
<br />
<table width="60%" align="center">
  <tr>
    <td><div align="right"> <span id="loading"></span>
      <input name="Submit" id="submit" type="submit" class="k-button" value="บันทึกข้อมูล"/>
      &nbsp;
      <input name="Reset" type="reset" class="k-button" value="ยกเลิก"/>
    </div></td>
  </tr>
</table>
<table width="60%" align="center" class="font">
  <tr>
    <td><table id="grid">
        <thead>
          <tr>
            <th data-field="Properties">Properties Item</th>
            <th data-field="Value">Value</th>
            <th data-field="Unit">Unit</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>Furnish Machine</td>
            <td><input name="textfield4" type="number" value="0" class="k-textbox number" id="ps11_1"/></td>
            <td>%</td>
          </tr>
          <tr>
            <td>Consistency</td>
            <td><input name="textfield5" type="number" value="0" class="k-textbox number" id="ps12_1"/></td>
            <td>%</td>
          </tr>
          <tr>
            <td>Freeness,CSF</td>
            <td><input name="textfield6" type="number" value="0" class="k-textbox number" id="ps13_1"/></td>
            <td>ml</td>
          </tr>
          <tr>
            <td>Drainage Time</td>
            <td><input name="textfield7" type="number" value="0" class="k-textbox number" id="ps14_1"/></td>
            <td>sec</td>
          </tr>
          <tr>
            <td>Basis Weight (BD.) </td>
            <td><input name="textfield8" type="number" value="0" class="k-textbox number" id="ps15_1"/></td>
            <td>gsm</td>
          </tr>
          <tr>
            <td>Caliper</td>
            <td><input name="textfield9" type="number" value="0" class="k-textbox number" id="ps16_1"/></td>
            <td>mm</td>
          </tr>
          <tr>
            <td>Density</td>
            <td><input name="textfield10" type="number" value="0" class="k-textbox number" id="ps17_1"/></td>
            <td>g/cm<sup>2</sup></td>
          </tr>
          <tr>
            <td>Bulk</td>
            <td><input name="textfield10" type="number" value="0" class="k-textbox number" id="ps18_1"/></td>
            <td>cm<sup>3</sup>/g</td>
          </tr>
          <tr>
            <td>Tensile Index</td>
            <td><input name="textfield10" type="number" value="0" class="k-textbox number" id="ps19_1"/></td>
            <td>N.m/g</td>
          </tr>
          <tr>
            <td>Tear Index</td>
            <td><input name="textfield10" type="number" value="0" class="k-textbox number" id="ps20_1"/></td>
            <td>mN.m<sup>2</sup>/g</td>
          </tr>
          <tr>
            <td>Burst Index</td>
            <td><input name="textfield10" type="number" value="0" class="k-textbox number" id="ps21_1"/></td>
            <td>kPa.m<sup>2</sup>/g</td>
          </tr>
          <tr>
            <td>Bending Stiffness Index</td>
            <td><input name="textfield10" type="number" value="0" class="k-textbox number" id="ps22_1"/></td>
            <td>mN/g</td>
          </tr>
          <tr>
            <td>Folding</td>
            <td><input name="textfield10" type="number" value="0" class="k-textbox number" id="ps23_1"/></td>
            <td>Times</td>
          </tr>
          <tr>
            <td>L*</td>
            <td><input name="textfield10" type="number" value="0" class="k-textbox number" id="ps24_1"/></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>a*</td>
            <td><input name="textfield" type="number" value="0" class="k-textbox number" id="ps25_1"/></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>b*</td>
            <td><input name="textfield2" type="number" value="0" class="k-textbox number" id="ps26_1"/></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>ISO Brightness</td>
            <td><input name="textfield3" type="number" value="0" class="k-textbox number" id="ps27_1"/></td>
            <td>%</td>
          </tr>
          <tr>
            <td>Opacity</td>
            <td><input name="textfield11" type="number" value="0" class="k-textbox number" id="ps28_1"/></td>
            <td>%</td>
          </tr>
          <tr>
            <td>Scattering Coeff.</td>
            <td><input name="textfield12" type="number" value="0" class="k-textbox number" id="ps29_1"/></td>
            <td>m<sup>2</sup>/kg</td>
          </tr>
          <tr>
            <td>Absorption Coeff.</td>
            <td><input name="textfield13" type="number" value="0" class="k-textbox number" id="ps30_1"/></td>
            <td>m<sup>2</sup>/kg</td>
          </tr>
          <tr>
            <td>CIE Whiteness</td>
            <td><input name="textfield14" type="number" value="0" class="k-textbox number" id="ps31_1"/></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>Porosity (Oil Gurley )</td>
            <td><input name="textfield15" type="number" value="0" class="k-textbox number" id="ps32_1"/></td>
            <td>sec / 100 ml</td>
          </tr>
          <tr>
            <td>Tensile stiffness index</td>
            <td><input name="textfield16" type="number" value="0" class="k-textbox number" id="ps33_1"/></td>
            <td>KN/Kg </td>
          </tr>
          <tr>
            <td>Ash</td>
            <td><input name="textfield17" type="number" value="0" class="k-textbox number" id="ps34_1"/></td>
            <td>%</td>
          </tr>
        </tbody>
      </table>
      <script>
                $(document).ready(function() {
                    $("#grid").kendoGrid({
						columns: [
						{ field: "Properties", width: "125px" },
						{ field: "Value", width: "20px" },
						{ field: "Unit",  width: "40px" }
						],
                        //height: 1000,
						//pageable: true,
						dataSource: {
						//pageSize: 12
						} 
                    });
                });
            </script></td>
  </tr>
</table>

<!--scrip list select--> 
<script>
                $(document).ready(function() {
                    var viewModel = {
                        chosenTicket: ko.observable(),
                        resetTicket: function() { this.chosenTicket(null) },
                    };
                    $("#ticket1").kendoDropDownList().trigger("change");
                    $("#ticket2").kendoDropDownList().trigger("change");
                    $("#ticket3").kendoDropDownList().trigger("change");
                    $("#ticket4").kendoDropDownList().trigger("change");
                });
      		</script> 
<!--scrip วัน-เดือน-ปี--> 
<script>
                $(document).ready(function() {
                    var today = new Date(),
                        birthdays = [
                           +new Date(today.getFullYear(), today.getMonth(), 11),
                           +new Date(today.getFullYear(), today.getMonth() + 1, 6),
                           +new Date(today.getFullYear(), today.getMonth() + 1, 27),
                           +new Date(today.getFullYear(), today.getMonth() - 1, 3),
                           +new Date(today.getFullYear(), today.getMonth() - 2, 22)
                        ];

                    $("#datepicker").kendoDatePicker({
                        value: today,
                        month: {
                            // template for dates in month view
                            content: '# if ($.inArray(+data.date, [' + birthdays + ']) != -1) { #' +
                                         '<div class="birthday"></div>' +
                                     '# } #' +
                                     '#= data.value #'
                        },
                        footer: "Today - #=kendo.toString(data, 'd') #"
                    });

                    $("#datepicker").data("kendoDatePicker")
                                    .dateView.calendar.element
                                    .width(300);
                });
            </script> 
<!--scrip เวลา--> 
<script>
                $(document).ready(function() {
                    // create TimePicker from input HTML element
                    $("#timepicker").kendoTimePicker();
                });
            </script> 
			<script>
					$("#submit").click(function(){
					     var pulpstrengthPS1 = $("#ticket1").val();
                         var pulpstrengthPS2 = $("#ticket2").val(); 
                         var pulpstrengthPS3 = $("#ticket3").val();  
                         var pulpstrengthPS4 = $("#ticket4").val();  
                         <?php 
						 for($i=11;$i<=34;$i++)
						 {
                         	echo "var pulpstrengthPS".$i."_1 = $(\"#ps".$i."_1\").val(); \n";
                         	//echo "var finalcheckFC".$i."_2 = $(\"#fc".$i."_2\").val(); \n";	
                         }
                         ?>  
                    if (confirm("ต้องการจะบันทึกข้อมูลหรือไม่ ?")) 
                        { 
		      //alert('<1>==>'+pulpstrengthPS11_1+'<2>==>'+pulpstrengthPS12_1);
			  var loading = "<img src='<?php echo base_url(); ?>css/BlueOpal/loading-image.gif?>'>";
		      $.ajax({
		      url : "<?php echo base_url();?>index.php/pulpstrength/getDataPulpStrength",
		      type: "POST",
		      data:({  
			  pulpstrengthPS2 : pulpstrengthPS2,
			  pulpstrengthPS3 : pulpstrengthPS3,
			  pulpstrengthPS4 : pulpstrengthPS4,
			  <?php 
			  for($i=11;$i<=34;$i++){
			  echo "pulpstrengthPS".$i."_1 : pulpstrengthPS".$i."_1, \n";
			  //echo "finalcheckFC".$i."_2 : finalcheckFC".$i."_2, \n";
			  }?> 
			  pulpstrengthPS1 : pulpstrengthPS1
		        	}),
				beforeSend : function()
				{
		        $("#loading").html(loading);
		        //$("#overlay").css('display','block'); // displaying the overlay
		        // jQuery("#popup").css('display','block'); // displaying the popup
		        //$("#submit").attr("disabled","disabled");
		        },
		        success : function(rs)
				{
		        alert(rs);
		        $("#loading").html('');
		        //$("#submit").removeAttr("disabled","disabled");
				<?php 
		        for($i=11;$i<=34;$i++){
		        echo " $(\"#ps".$i."_1\").val('0'); \n";
		       // echo "  $(\"#fc".$i."_2\").val('0'); \n";	
		        }
		        ?> 
				}						
				})
				}
		        });
            </script> 
